//
//  Global.h
//  Gruphoto
//
//  Created by Thao Nguyen Huy on 1/3/13.
//  Copyright (c) 2013 CNC Software. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

#define kPaddingLeft        8.0f
#define kPaddingTop         8.0f
#define kSpaceWidth         4.0f
#define kSpaceHeight        5.0f
#define kViewWidth          97.0f
#define kViewHeight         87.0f

typedef enum {
    LoginTypeAppAccount,
    LoginTypeFacebook
}LoginType;

typedef enum {
    EventDetailModeLive,
    EventDetailModePost,
    EventDetailModeJoin,
    EventDetailModeCreate,
    EventDetailModeSetting,
    EventDetailModeUserDetail,
    EventDetailModeDetailInSettings
}EventDetailMode;

typedef enum {
    EventEditModeCreate,
    EventEditModeUpdate
}EventEditMode;

typedef enum {
    AccountEditModeRegister,
    AccountEditModeUpdate
}AccountEditMode;

typedef enum {
    AnnotationViewModeSmall,
    AnnotationViewModeLarge
}AnnotationViewMode;

typedef enum {
    EventMapModeNormal,
    EventMapModeSearch
}EventMapMode;

typedef enum {
    ActionSheettagNone,
    ActionSheettagAddPhoto,
    ActionSheetTagSettings,
    ActionSheetTagShare    
}ActionSheettag;

typedef enum {
    AlertViewTagNone,
    AlertViewTagFirstMessage,
    AlertViewTagEnterCode,
    AlertViewTagEmailMissing,
    AlertViewTagEmailInvalid,
    AlertViewTagPasswordMissing,
    AlertViewTagFirstNameMissing,
    AlertViewTagLastNameMissing,
    AlertViewTagForgotPassword,
    AlertViewTagEmailMissingInForgotPassword,
    AlertViewTagWelcomeToCreatedEvent,
    AlertViewTagPasscodeMissing
}AlertViewTag;

typedef enum {
    RequestTagNone,
    RequestTagRegisterAccount,
    RequestTagLoginAppAccount,
    RequestTagLoginWithFacebook,
    RequestTagForgotPassword,
    RequestTagCreateEvent,
    RequestTagUploadPhoto,
    RequestTagGetJoinableEvents,
    RequestTagJoinToEvent,
    RequestTagGetDetailsOfEvent,
    RequestTagGetLiveEvents,
    RequestTaggetPostedEvents
}RequestTag;

typedef enum {
    ErrorCodeUnknow = -2,
    ErrorCodeNoPermission = -1,
    ErrorCodeNone = 200,
    ErrorCodeUserBlockedInEvent = 234,
    ErrorCodeUserTokenNotSet,
    ErrorCodeDeviceTokenNotSet,
    ErrorCodeUserIdNotSet,
    ErrorCodeFriendIdNotSet,
    ErrorCodeImageIdNotSet,
    ErrorCodeEventIdNotSet,
    ErrorCodeEventCodeNotSet,
    ErrorCodeWrongEmailOrPassword,
    ErrorCodeWrongPassword,
    ErrorCodeEmailExisted,
    ErrorCodeEmailInvalid,
    ErrorCodeGetMethodRequired,
    ErrorCodePostMethodRequired,
    ErrorCodeCommentParentNotFound,
    ErrorCodeImageNotFound,
    ErrorCodeEventBlocked,
    ErrorCodeEventNotFound,
    ErrorCodeFriendBlocked,
    ErrorCodeFriendNotFound,
    ErrorCodeUserBlocked,
    ErrorCodeUserNotFound = 255
}ErrorCode;

typedef enum {
    GPPlaceTypeUnknow,
    GPPlaceTypeNormal
}GPPlaceType;

typedef enum{
    TableViewDisplayTypeByFilterFavorite,
    TableViewDisplayTypeByNewest
}TableViewDisplayType;


// API links
#define kServerUrl  @"http://ec2-79-125-57-47.eu-west-1.compute.amazonaws.com"

#define kRegisterAccountUrl \
[NSString stringWithFormat:@"%@%@", kServerUrl, @"/api/user/register"]

#define kLoginWithAppAccountUrl \
[NSString stringWithFormat:@"%@%@", kServerUrl, @"/api/user/login"]

#define kForgotPasswordUrl \
[NSString stringWithFormat:@"%@%@", kServerUrl, @"/api/user/forgot_password"]

#define kCreateEventUrl \
[NSString stringWithFormat:@"%@%@", kServerUrl, @"/api/event/create_event"]

#define kUploadPhotoToEventUrl \
[NSString stringWithFormat:@"%@%@", kServerUrl, @"/api/event/upload_event_image"]

#define kGetJoinableEventsUrl \
[NSString stringWithFormat:@"%@%@", kServerUrl, @"/api/event/get_joinable_events"]

#define kJoinToEventUrl \
[NSString stringWithFormat:@"%@%@", kServerUrl, @"/api/event/join_event"]

#define kGetDetailsOfEventUrl \
[NSString stringWithFormat:@"%@%@", kServerUrl, @"/api/event/get_event_detail"]

#define kLikeUnlikePhoto \
[NSString stringWithFormat:@"%@%@", kServerUrl, @"/api/event/vote_photo"]

#define kLoginWithFacebookUrl \
[NSString stringWithFormat:@"%@%@", kServerUrl, @"/api/user/login_via_facebook"]

#define kGetLiveEventsUrl \
[NSString stringWithFormat:@"%@%@", kServerUrl, @"/api/event/get_live_events"]

#define kGetPostedEventUrl \
[NSString stringWithFormat:@"%@%@", kServerUrl, @"/api/event/get_posted_events"]

//height of cell
#define kHeightEventPhotoCell 91

// API Keys
#define kEvents         @"events"
#define kUser           @"user"
// Users
#define kUserId         @"user_id"
#define kEmail          @"email"
#define kPassword       @"password"
#define kPhone          @"phone"
#define kFirstName      @"first_name"
#define kLastName       @"last_name"
#define kPhoto          @"photo"
#define kUserToken      @"user_token"
#define kDeviceToken    @"device_token"
#define kNumFollower    @"num_follower"
#define kNumLike        @"num_like"
#define kNumPhoto       @"num_photo"
#define kNumEvent       @"num_event"
#define kSocialId       @"social_id"
#define kName           @"name"

// friends
#define kFriendId       @"friend_id"
#define KFollwed        @"followed"

// Events
#define kEventId        @"event_id"
#define kNumMember      @"num_member"
#define kLongitude      @"longitude"
#define kLatitude       @"latitude"
#define kPlaceAddress   @"place_address"
#define kTimeLimit      @"time_limit"
#define kPassTime       @"pass_time"
#define kTitle          @"title"
#define kDescription    @"description"
#define kPlaceName      @"place_name"
#define kCreatedDate    @"created_date"
#define kIsPublic       @"is_public"
#define kDistance       @"current_distance"
#define kCode           @"code"
#define kDistrance      @"current_distance"
#define kJoining        @"joining"
#define kImages         @"images"
#define kUsers          @"users"

// Images
#define kImageId        @"image_id"
#define kSource         @"source"
#define kNumComment     @"num_comment"
#define kVote           @"vote"
#define kImageNumLike   @"num_like"

// Comments
#define kCommentId         @"comment_id"
#define kParentCommentId   @"parent_comment_id"
#define kContent           @"content"
#define kNumReply          @"num_reply"

// Reports
#define kReportId   @"report_id"
#define kTo         @"to"
#define kCc         @"cc"
#define kBcc        @"bcc"

// Errors
#define kErrorCode      @"error_code"
#define kErrorMessage   @"error_message"

typedef enum {
    GPFacebookLoginTypeNone,
    GPFacebookLoginTypeAccessApp,
    GPFacebookLoginTypeFindNearbyPlace,
    GPFacebookLoginTypeSharePhoto
}GPFacebookLoginType;

// Global variables
extern NSInteger whereEventCome;
extern GPFacebookLoginType facebookLoginType;
extern NSString *const GPFacebookSessionStateChangedNotification;
extern NSString *const GPFacebookSessionDidOpenedNotification;
extern NSString *const GPFacebookSessionDidClosedNotification;
extern NSString *const GPFacebookSessionDidFailedNotification;

@interface Global : NSObject

+ (float)systemVersion;
+ (float)screenHeight;
+ (BOOL)isIphone5;
+ (BOOL)isValidEmail:(NSString *)email;
+ (UIImage *)resizeImage:(UIImage *)image tosize:(CGSize)targetSize;

@end
